#include <stdio.h>

#ifndef MAX
#define MAX 50001
#endif

int f[MAX], r[MAX];

/**************************************
* Funciont Name: init_set
* Params: void
* Return: int
* Description: 
**************************************/

int init_set (void)
{
    int i;

    for (i = 0; i < MAX; i++) {
        f[i] = i;
        r[i] = 1;
    }

    return 0;
}

/**************************************
* Funciont Name: find_set
* Params: int x
* Return: int
* Description: 
**************************************/

int find_set (int x)
{

    if (f[x] == x) {
        return x;
    } else {
        f[x] = find_set(f[x]);
    }

    return f[x];
}

/**************************************
* Funciont Name: union_set
* Params: int x, int y
* Return: int
* Description: 
**************************************/

int union_set (int x, int y)
{

    int a = find_set(x);
    int b = find_set(y);

    if (a == b) {
        return 0;
    } else if (r[a] <= r[b]) {
        f[a] = b;
        r[b] += r[a];
    } else {
        f[b] = a;
        r[a] += r[b];
    }

    return 1;
}

int main (int argc, char const* argv[])
{
    int i, m, n, ans, case_cnt;
    case_cnt = 1;

    while (scanf("%d %d", &n, &m) != EOF && (n || m)) {
        ans = n;
        init_set();

        for (i = 0; i < m; i++) {
            int a, b;
            scanf("%d %d", &a, &b);
            ans -= union_set(a, b);
        }

        printf("Case %d: %d\n", case_cnt++, ans);
    }

    return 0;
}
